<script setup lang="ts">
import { ref ,onMounted} from 'vue';
import { useRouter } from 'vue-router';
import { getbody } from '@/api/body';
import { useCounterStore } from '@/stores/counter';
import type { Ref } from 'vue';
const router = useRouter()
const activeId = ref(1);
const activeIndex = ref(0);
const item : Ref<any[]>= ref([])
function onClickLeft(){
    router.back()
}
onMounted(()=>{
    getbody().then(res=>{
        item.value = res.data.data
    })
})

const use = useCounterStore()
function setbody(){
    use.getbody(item.value[activeIndex.value].children[(activeId.value-(activeIndex.value)*10)-1].text)
    // console.log(use.body);
    router.back()
}
</script>
<template>
    <div class="box_city">
        <van-nav-bar title="病历切换" left-text="返回" left-arrow @click-left="onClickLeft" />
        <van-tree-select v-model:active-id="activeId" v-model:main-active-index="activeIndex" :items="item" height="100%" @click="setbody"/>
    </div>
</template>
<style lang="scss" scoped>
.box_city{
    width: 100%;
}
</style>